//
//  HYMovieDateTableViewCell.m
//  KaiJing
//
//  Created by lanou on 16/1/13.
//  Copyright © 2016年 HuangZuCui. All rights reserved.
//

#import "HYMovieDateTableViewCell.h"
#import "UIView+WLFrame.h"
#import "UIImageView+WebCache.h"
@implementation HYMovieDateTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //头像
        _headerImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
        _headerImage.backgroundColor = kRandomClolor;
        [self.contentView addSubview:_headerImage];
        
        //昵称
        _author = [[UILabel alloc] initWithFrame:CGRectMake(_headerImage.right + 10, _headerImage.top, kScreenWidth / 2, 20)];
        _author.backgroundColor = kRandomClolor;
        [self.contentView addSubview:_author];
        
        //时间
        _dateline = [[UILabel alloc] initWithFrame:CGRectMake(_author.left, _author.bottom + 10, _author.width, _author.height)];
        _dateline.backgroundColor = kRandomClolor;
        [self.contentView addSubview:_dateline];
        
        _message = [[UILabel alloc] initWithFrame:CGRectMake(_author.left, _dateline.bottom + 20, kScreenWidth - 90, 60)];
        _message.backgroundColor = kRandomClolor;
        [self.contentView addSubview:_message];
        
        
        _praise = [UIButton buttonWithType:(UIButtonTypeSystem)];
        _praise.frame = CGRectMake(_message.left, _message.bottom + 20, 30, 30);
        _praise.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_praise];
        
        //回复
        _reply = [UIButton buttonWithType:(UIButtonTypeSystem)];
        _reply.frame = CGRectMake(kScreenWidth - 50, _praise.top, 30, 30);
        _reply.backgroundColor = kRandomClolor;
        [self.contentView addSubview:_reply];
        
    }
    return self;
}

- (void)setModel:(HYMovieTableModel *)model {
    _model = model;
    
    _author.text = model.author;
    _dateline.text = model.dateline;
    _message.text = model.message;
   // SZLog(@"%@",model.attachments);
    for (NSDictionary *dic in model.attachments) {
        SZLog(@"%@",dic);
        NSString *header = dic[@"thumb"];
        NSString *headerUrl = [NSString stringWithFormat:@"http://morguo.com/%@",header];
        [_headerImage sd_setImageWithURL:[NSURL URLWithString:headerUrl] placeholderImage:[UIImage imageNamed:@"recommend_selected"]];
    }

    
    
}


@end
